<template>
	<view class="w-100">
		<view class="flex-1 row py-4">
			<view class="row-ac font-s-35 text-light-grey">
				<view class="">本月累计提现</view>
				<view class="ml-3">{{ balanceInfo.used_amount }}元</view>
			</view>
		</view>
		<view class="flex-1 list-box">
			<view class="flex-1 py-3">
				<view class="py-3 flex-1 mx-3 border-bottom row-ac" v-for="(item,index) in distributiondataList"
					:key="index">
					<view class="flex-1">
						<view class="font-s-5 font-w">{{ item.audit_state | auditstateFilter }}</view>
						<view class="font-s-35 mt-1">提现到{{ item.withdrawal_method | valFilter }}</view>
						<view class="font-s-2 mt text-muted">{{ item.create_time }}</view>
					</view>
					<view class="row-ac font-s-45 font-w" :class="item.audit_state == 0 ? '' : 'cl-warning'">
						<view>-</view>
						<view class="ml-1">{{ item.amount }}</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		userInfoUrl,
		usersbalanceUrl
	} from '@/api/index.js';
	import {
		distributorsDetailUrl,
		distributorsSubUrl,
		distributiondataListUrl
	} from '@/api/promotion';
	export default {
		data() {
			return {
				userInfo: '',
				distriSubList: [],
				queryInfo: {
					types: '',
					page_size: 10
				},
				distributiondataList: [],
				balanceInfo:''
			}
		},
		filters: {
			auditstateFilter(val) {
				if (val === 0) {
					return '提现中'
				} else if (val === 1) {
					return '提现成功'
				} else if (val === 3) {
					return '提现失败'
				}
			},
			valFilter(val) {
				if (val === 0) {
					return '微信账户'
				} else if (val === 1) {
					return '支付宝账户'
				} else if (val === 2) {
					return '银行账户'
				}
			}
		},
		mounted() {
			this.token = uni.getStorageSync('token')
			if (this.token != '') {
				this.loginStatus = true
				this.getUserInfo()
			} else {
				this.loginStatus = false
			}
			this.getDistributiondataList()
			this.getUsersbalance()
		},
		methods: {
			getUserInfo() {
				this.$R.get(userInfoUrl).then(res => {
					this.userInfo = res.data
					this.getDistributorsSub(this.userInfo.id)
				})
			},
			getUsersbalance() {
				this.$R.get(usersbalanceUrl).then(res => {
					this.balanceInfo = res.data
				})
			},
			getDistributiondataList() {
				this.$R.get(distributiondataListUrl, this.queryInfo).then(res => {
					this.distributiondataList = res.data.list
					this.distributiondataTotal = res.data.total
					console.log(this.distributiondataList);
				})
			},
			navTo(item) {
				uni.navigateTo({
					url: item.url
				});
			}
		}
	}
</script>

<style>
	page {
		background-color: #f5f5f5;
	}

	.list-box {
		background-color: #fff;
		border-radius: 42rpx 42rpx 0 0;
	}

	.cl-warning {
		color: #EA660B;
	}

	.cl-red {
		color: #E43900;
	}

	.cl-green {
		color: #1A9700;
	}
</style>